<template>
  <avue-crud :data="list.planningRegisterinfoList"
             :option="option"
             @on-load="getList">
    <!--<template slot-scope="scope"-->
              <!--slot="menu">-->
      <!--<div class="menu-title"-->
           <!--@click.stop="showRegisterDetail(scope.row,scope.index)">-->
        <!--<i class="iconfont iconview icon-primary"></i>-->
        <!--<p class="menu-title-text">详情</p>-->
      <!--</div>-->
    <!--</template>-->
  </avue-crud>
</template>

<script>
import { getbasisinfo } from "@/api/planning/detailList";
import { PROJECT_DIC } from "@/const/dict";

export default {
  name: "listRegisterInfo",
  components: {
  },
  data () {
    return {
      option: {
        page: true,
        addBtn: false,
        editBtn: false,
        addRowBtn: false,
        indexLabel: "序号",
        index: true,
        indexWidth:70,
        cellBtn: false,
        delBtn: false,
        columnBtn: false,
        refreshBtn: false,
        filterBtn: false,
        searchBtn: false,
        menuWidth: 100,
        menu:false,
        keyId: "id",
        column: [
          {
            label: "规划名称",
            width: 440,
            prop: "title",
            cell: true,
            formatter: function (row, value, label, column) {
              return '<a style="cursor: pointer;" onclick="showRegisterDetail(\'' + row.registerinfoId  + '\')">' + value + '</a>';
            },
          },
          {
            label: "申报(牵头)单位",
            prop: "orgName",
            type: "select",
            dicData: PROJECT_DIC.ORG_CODE,
            cell: true
          },
          {
            label: "发布层级",
            prop: "approvingAuthorityLevel",
            type: "select",
            dicData: PROJECT_DIC.APPROVING_AUTHORITY_LEVEL,
            cell: true
          },
          {
            label: "规划等级",
            prop: "planningRank",
            type: "select",
            dicData: PROJECT_DIC.PLANNING_RANK,
            cell: true
          }
        ]
      },
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 20 // 每页显示多少条
      },
      list: {
        planningRegisterinfoList: []
      }
    };
  },
  props: {
    listId: {
      type: [Number, String],
      required: true
    }
  },
  created () {
    this.getList();
    window.showRegisterDetail = this.showRegisterDetail;
  },
  watch: {
    listId () {
      this.getList();
    }
  },
  methods: {
    getList (page) {
      if (this.listId == null) {
        return false;
      }
      this.page = page;
      getbasisinfo(this.listId).then((res) => {
        this.list = res.data.data;
      });
    },
    showRegisterDetail (registerinfoId) {
      let src = `/regDetail/detail/${registerinfoId}`;
      this.$router.push({
        path: src
      })
    },
  }
}
</script>
